package com.example.demo.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Aspect
@Slf4j
@Component
public class DemoAspect {

  @Pointcut("execution(public * com.example.demo.controller.*.*(..))")
  public void log() {

  }

  @Before("log()")
  public void doBefore(JoinPoint joinPoint) {
    String signName = joinPoint.getSignature().getName();
    String name = Thread.currentThread().getName();
    log.info(">>>> signName:{}, thread name:{}", signName, name);
  }
}